package com.sezi.blog.controller;
/**
 * user控制器
 * */
import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sezi.blog.entity.User;
import com.sezi.blog.service.IUserService;

@Controller
@RequestMapping("/user")
public class UserController {
	
	@Resource
	private IUserService userService;
	
	@RequestMapping(value="/{id}",method={RequestMethod.GET})
	@ResponseBody
	public User getUserInfo(@PathVariable Long id){
		User user = userService.findOne(id);
		return user;
	}
	
	@RequestMapping(value="",method={RequestMethod.POST})
	@ResponseBody
	public String addUser(User user){
		try{
			userService.save(user);
		}catch(Exception e){
			return "fail";
		}
		return "success";
	}
}
